<template>
    <section>
        <el-card>
    <el-table
            :data="k8snodes"
            stripe
            style="width: 100%"
            :row-style="rowStyle"
    >
        <el-table-column

                width="40">
            <template slot-scope="scope">
                <i :class="scope.row.status !== 'Ready' ? 'fa fa-info-circle' : 'fa fa-check-circle'"
                   :style="scope.row.status !== 'Ready' ? 'font-size:18px;color:red' : 'font-size:18px;color:green'"
                >

                </i>

            </template>



        </el-table-column>

        <el-table-column
                prop="name"
                label="名称"
                width="180">
            <template slot-scope="scope">
                <el-link :href="'#/kubernetes/node/' + scope.row.name"  type="primary" :underline="false" icon="el-icon-office-building">{{scope.row.name}}</el-link>
            </template>
        </el-table-column>



        <el-table-column
                prop="ip"
                label="地址"
                width="180">

        </el-table-column>
        <el-table-column
                prop="labels"
                label="标签">
            <template slot-scope="scope">
                <div v-for="(v,k) in scope.row.labels">
                <el-tag  type="info" size="mini">{{k}}: {{v}}</el-tag>
                </div>
            </template>


        </el-table-column>
        <el-table-column
                prop="status"
                label="状态">
            <template slot-scope="scope">
                <el-tag
                        size="mini"
                        :type="scope.row.status !== 'Ready' ? 'danger' : 'success'"
                        :style="scope.row.status !== 'Ready' ? 'color: red' : 'color: green'"
                        disable-transitions>{{scope.row.status}}</el-tag>
            </template>

        </el-table-column>
        <el-table-column
                prop="cpu"
                label="cpu">
        </el-table-column>
        <el-table-column
                prop="memory"
                label="内存">
        </el-table-column>
        <el-table-column
                prop="joindate"
                label="创建时间">
        </el-table-column>
    </el-table>
        </el-card>
    </section>
</template>

<script>
    import { k8sNodesData } from '../../api/api'
    export default {
        data() {
            return {
                k8snodes: [],
            }
        },
        methods: {
            rowStyle({ row, rowIndex}){
                return "height:50px;"
            },
            getK8sNodesData(){
                let self = this
                k8sNodesData().then((res) => {
                    console.log(res)
                    this.k8snodes = res.nodes
                })

            },
        },
        mounted: function () {
            console.log("debug ehrer")
            this.getK8sNodesData()

        }
    }
</script>